package com.gnkexy.springframework.test.bean;

import com.gnkexy.springframework.beans.factory.*;
import com.gnkexy.springframework.beans.factory.support.BeanFactory;
import com.gnkexy.springframework.context.ApplicationContext;
import com.gnkexy.springframework.context.ApplicationContextAware;

public class UserService implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, BeanFactoryAware {

    private String uid;

        private IUserDao userDao;
//    private UserDao userDao;

    private String company;

    private String location;

    private BeanFactory beanFactory;

    private ApplicationContext applicationContext;

    public String queryUserInfo() {
        return userDao.queryUserName(uid) + ", 公司：" + company + ", 地点: " + location;
    }


    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public IUserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public BeanFactory getBeanFactory() {
        return beanFactory;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    //    @Override
//    public void afterPropertiesSet() {
//        System.out.println("执行：userService的afterPropertiesSet初始化方法");
//    }
//
//    @Override
//    public void destroy() {
//        System.out.println("执行：userService的destroy销毁方法");
//    }

//    public void Myinit() {
//        System.out.println("执行：userService自定义的init-method初始化方法");
//    }
//
//    public void Mydestroy() {
//        System.out.println("执行：userService自定义的destroy-method销毁方法");
//    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("ClassLoader:    " + classLoader);
    }

    @Override
    public void setBeanName(String Name) {
        System.out.println("BeanName:    " + Name);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
}
